<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	</head>
	<body>
		<div id="web">
			<div class="background1">
				<div class="progress">
					<img src="img/progress_bg.png" />
				</div>
				<div class="progress2">
					<img src="img/progress_bar.jpg" />
				</div>
				<div class="bottle">
					<img src="img/big_pingzi.png" />
				</div>
				<div class="boom">
					<img src="img/boom.png" />
				</div>
				<div class="spark">
					<img src="img/huohua.png" />
				</div>
			</div>
		
		<script src="js/vconsole.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			
			if(window.DeviceMotionEvent) {
				window.addEventListener('devicemotion', deviceMotionHandler, false);
			}
				var SHAKE_THRESHOLD = 800;
				var last_update = 0;
				var x = y = z = last_x = last_y = last_z = 0;
				var num = 0;
				function deviceMotionHandler(eventData) {
					var acceleration = eventData.accelerationIncludingGravity;
					var curTime = new Date().getTime();
				
					if((curTime - last_update) > 100) {
						var diffTime = curTime - last_update;
						last_update = curTime;
						x = acceleration.x;
						y = acceleration.y;
						z = acceleration.z;
						var speed = Math.abs(x + y + z - last_x - last_y - last_z) / diffTime * 10000;
				
						if(speed > SHAKE_THRESHOLD) {
							doResult();
						}
						last_x = x;
						last_y = y;
						last_z = z;
					}
				}
			var arr = ["result1.html","result2.html","result3.html","result4.html"];
			function doResult(n) {
//				         var id = Math.ceil(Math.random()*4);
//				         var res= arr[id];
//				     }
					num++
				     console.log(num)
				     if(num = 20){
				     	return num;
				     	window.location.href = "result1.html";
				     	else{
				     		return num;
				     		window.location.href = "result2.html";
				     	}
				     }
				}
			
			
			
		</script>
		
		
	</body>
</html>
